package render.materials.shaders
{
	import utils.adobe.AGALMiniAssembler;
	
	import flash.display3D.Context3D;
	import flash.display3D.Context3DProgramType;
	import flash.display3D.Program3D;

	/**
	 *着色器 
	 * @author devin
	 * 
	 */	
	public class Shader2D
	{
		private var _program3D:Program3D;
		private var _context3D:Context3D;
		private var _vertexProgram:AGALMiniAssembler;
		private var _fragmentProgram:AGALMiniAssembler;
		
		/**
		 *着色器 
		 * @param context3D
		 * @param vertexShaderString
		 * @param fragmentShaderString
		 * 
		 */
		public function Shader2D(context3D:Context3D, program3D:Program3D, vertexShaderString:String, fragmentShaderString:String)
		{
			_context3D=context3D;
			_program3D=program3D;
			_vertexProgram=new AGALMiniAssembler();
			_vertexProgram.assemble(Context3DProgramType.VERTEX, vertexShaderString);
			
			_fragmentProgram = new AGALMiniAssembler();
			_fragmentProgram.assemble(Context3DProgramType.FRAGMENT, fragmentShaderString);
			_program3D.upload(_vertexProgram.agalcode, _fragmentProgram.agalcode)
		}

		public function dispose():void
		{
			_context3D=null;
			_vertexProgram=null;
			_fragmentProgram=null;
			_program3D=null;
		}
	}
}